﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Media.Media3D;

namespace Kinect.KinectMouseControl
{
    public class AbsoluteMouseTranslation : IMouseTranslation
    {
        private System.Drawing.Rectangle _translationRectangle;
        private readonly float _boxWidth;
        private readonly float _boxTop;
        private readonly float _boxBottom;

        public AbsoluteMouseTranslation(System.Drawing.Rectangle translationRectangle,
            float boxWidth,
            float boxTop,
            float boxBottom
            )
        {
            _translationRectangle = translationRectangle;
            _boxWidth = boxWidth;
            _boxTop = boxTop;
            _boxBottom = boxBottom;
        }

        #region IMouseTranslation Members

        public System.Drawing.Point Translate(Point3D pointF)
        {
            return new System.Drawing.Point(
                Convert.ToInt32(Utilities.ScaleNumber(Convert.ToSingle(pointF.X), -_boxWidth, _boxWidth, _translationRectangle.Left, _translationRectangle.Right)),
                Convert.ToInt32(Utilities.ScaleNumber(Convert.ToSingle(-pointF.Y), _boxBottom, _boxTop, _translationRectangle.Top, _translationRectangle.Bottom))
                );
        }

        #endregion
    }
}
